import { dateFormat } from '@vimi/utils-tool'

export const enumLoanGua = {
  1: '贷款担保',
  2: '债券担保',
}

export const tableColumns = [
  { attrs: { label: '归属省', prop: 'address_name_pro', align: 'center', minWidth: 120 } },
  { attrs: { label: '归属市', prop: 'address_name_city', align: 'center', minWidth: 120 } },
  { attrs: { label: '归属县', prop: 'address_name_county', align: 'center', minWidth: 120 } },
  { attrs: { label: '客户类型', prop: 'org_class_name', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '受保企业名称或贷款人姓名',
      prop: 'customer_name',
      align: 'center',
      minWidth: 200,
    },
  },
  { attrs: { label: '受保企业联系人姓名', prop: 'corp_name', align: 'center', minWidth: 120 } },
  { attrs: { label: '受保企业联系人电话', prop: 'corp_phone', align: 'center', minWidth: 120 } },
  {
    attrs: { label: '三证合一', prop: 'is_cert_merge', align: 'center', minWidth: 80 },
    process: v => (v === 1 ? '是' : '否'),
  },
  { attrs: { label: '统一社会信用代码', prop: 'register_no', align: 'center', minWidth: 120 } },
  // 列表显示，值全为0，不能修改 @twf_20210219
  {
    attrs: { label: '组织机构代码', prop: 'register_no', align: 'center', minWidth: 120 },
    process: _ => 0,
  },
  { attrs: { label: '身份证号码', prop: 'id_card', align: 'center', minWidth: 120 } },
  {
    attrs: { label: '行业', prop: 'parent_industrial_class', align: 'center', minWidth: 120 },
    process: v => v || '农、林、牧、渔业',
  },
  { attrs: { label: '行业小类', prop: 'industrial_class', align: 'center', minWidth: 120 } },
  { attrs: { label: '销售收入(万元)', prop: 'sale_income', align: 'center', minWidth: 120 } },
  { attrs: { label: '资产总额(万元)', prop: 'assets_funds', align: 'center', minWidth: 120 } },
  { attrs: { label: '从业人数(人)', prop: 'emp_total', align: 'center', minWidth: 120 } },
  {
    attrs: { label: '担保业务类型', prop: 'loan_gua', align: 'center', minWidth: 120 },
    process: v => enumLoanGua[v] || '',
  },
  { attrs: { label: '放款银行名称', prop: 'bank_name', align: 'center', minWidth: 120 } },
  { attrs: { label: '贷款用途', prop: 'funds_use_dir', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '担保（放款）金额（万元）',
      prop: 'warranty_amount',
      align: 'center',
      minWidth: 120,
    },
  },
  {
    attrs: {
      label: '担保机构与受保企业合同号',
      prop: 'gua_contract',
      align: 'center',
      minWidth: 120,
    },
  },
  {
    attrs: { label: '放款日期', prop: 'load_date', align: 'center', minWidth: 120 },
    process: v => dateFormat(v, 'yyyy/MM/dd'),
  },
  {
    attrs: { label: '还款日期', prop: 'load_end_date', align: 'center', minWidth: 120 },
    process: v => dateFormat(v, 'yyyy/MM/dd'),
  },
  { attrs: { label: '年化费率', prop: 'warranty_rate', align: 'center', minWidth: 120 } },
  { attrs: { label: '已收担保费', prop: 'recieved_gua_fee', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '收取其它费用（包括评审费等）',
      prop: 'other_cost',
      align: 'center',
      minWidth: 130,
    },
  },
  { attrs: { label: '收取受保企业保证金', prop: 'income_margin', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '贷款银行与受保企业合同号',
      prop: 'ensurce_contract',
      align: 'center',
      minWidth: 120,
    },
  },
  { attrs: { label: '银行贷款利率', prop: 'load_rate', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '担保机构向金融机构存入保证金',
      prop: 'repo_margin',
      align: 'center',
      minWidth: 120,
    },
  },
  { attrs: { label: '备注', prop: 'remark', align: 'center', minWidth: 120 } },
  { attrs: { label: '公司放款流水号', prop: 'loan_number', align: 'center', minWidth: 120 } },
  {
    attrs: {
      label: '银行确认放款金额',
      prop: 'confirm_reply_funds',
      align: 'center',
      minWidth: 120,
    },
    process: v => v || '',
  },
]

export const fields = ['customer_related_id', ...tableColumns.map(it => it.attrs.prop)]

export const dataAdapter = item => {
  item.is_cert_merge = +item.is_cert_merge
  item.confirm_reply_funds = +item.confirm_reply_funds
  item.loan_gua = +item.loan_gua
  return item
}
